<?php
defined('JPATH_BASE') or die();

/**
 * Renders a list element
 *
 * @package 	Joomla.Framework
 * @subpackage		Parameter
 * @since		1.5
 */

class JElementStylies extends JElement
{
	/**
	* Element type
	*
	* @access	protected
	* @var		string
	*/
	var	$_name = 'stylies';

	function fetchElement($name, $value, &$node, $control_name)
	{
	  //Get value of layout style from database
	   $db = &JFactory::getDBO();
	   $cId = JRequest::getVar('cid','');
       if($cId !='') $cId = $cId[0];
       if($cId == ''){
           $cId = JRequest::getVar('id');
       }
       $sql = "SELECT params FROM #__modules WHERE id=$cId";
       $db->setQuery($sql);
       $paramsConfigObj = $db->loadObjectList();
       $aryParams = explode("\n",$paramsConfigObj[0]->params);
       foreach($aryParams as $item){
           $posStyle = strpos(trim($item),'layout_style=');   
       if($posStyle === false){
       } else {
           $layoutStyle = substr(trim($item),$posStyle+(int)strlen('layout_style='));
       }
       }                         
       //End get value of layout style       
	   $class = ( $node->attributes('class') ? 'class="'.$node->attributes('class').'"' : 'class="inputbox"' );
	   $options = array ();		
		for($i=1;$i<=5;$i++){
		  $val = "jv_slide$i";
		  $text = "JV slideshow$i";
		  $options[] = JHTML::_('select.option', $val, JText::_($text));
		}
		?>
		<script type="text/javascript">		
		  window.addEvent('domready',function(){		     
		      var rowAuto = $('paramsautorun0').getParent().getParent(); 
		      var rowS1EventType = $('paramsevent_type').getParent().getParent();
              var rowS2ModWidth = $('paramsmodule_width').getParent().getParent();
              var rowS2StyleEffect = $('paramsstyle_effect').getParent().getParent();
              var rowS4NoItem = $('paramsnumber_items_per_line').getParent().getParent();
              var rowS4FrameWidth = $('paramsframe_width').getParent().getParent();
              var rowS3SlideWidth = $('paramsvslide_width').getParent().getParent();
              var rowS3SlideBarWidth = $('paramsvslidebar_width').getParent().getParent();
              var rowS3ItemHeight = $('paramsvitem_height').getParent().getParent();
              var rowS3ImgWidth = $('paramsvimg_width').getParent().getParent();
              var rowS3ImgHeight = $('paramsvimg_height').getParent().getParent();
              var rowS3StyleEffect = $('paramsvstyle_effect').getParent().getParent();
              var rowS5ModWidth = $('paramsmoduleslide5_width').getParent().getParent();
              var rowS5StyleEffect = $('paramsslide5_effect').getParent().getParent();
              var rowS5ImgWidth = $('paramssimge5_width').getParent().getParent();
              var rowS5ImgHeight = $('paramssimg5_height').getParent().getParent();
              var rowS5ReadMore = $('paramsslide5_readmore0').getParent().getParent(); 
              var layout = "<?php echo $layoutStyle; ?>";
              switch(layout){
                    case "jv_slide1":
                      rowS1EventType.setStyle('display','');
                      rowAuto.setStyle('display',''); 
                      rowS2ModWidth.setStyle('display','none');
                      rowS2StyleEffect.setStyle('display','none');
                      rowS4NoItem.setStyle('display','none'); 
                      rowS4FrameWidth.setStyle('display','none');
                      rowS3SlideWidth.setStyle('display','none');
                      rowS3SlideBarWidth.setStyle('display','none');
                      rowS3ItemHeight.setStyle('display','none');
                      rowS3ImgWidth.setStyle('display','none');
                      rowS3ImgHeight.setStyle('display','none');
                      rowS3StyleEffect.setStyle('display','none');
                      rowS5ModWidth.setStyle('display','none');
                      rowS5StyleEffect.setStyle('display','none');
                      rowS5ImgWidth.setStyle('display','none');
                      rowS5ImgHeight.setStyle('display','none');
                      rowS5ReadMore.setStyle('display','none');                      
                    break;
                    case "jv_slide2":
                      rowS1EventType.setStyle('display','none');
                      rowAuto.setStyle('display',''); 
                      rowS2ModWidth.setStyle('display','');
                      rowS2StyleEffect.setStyle('display','');
                      rowS4NoItem.setStyle('display','none'); 
                      rowS4FrameWidth.setStyle('display','none');
                      rowS3SlideWidth.setStyle('display','none');
                      rowS3SlideBarWidth.setStyle('display','none');
                      rowS3ItemHeight.setStyle('display','none');
                      rowS3ImgWidth.setStyle('display','none');
                      rowS3ImgHeight.setStyle('display','none');
                      rowS3StyleEffect.setStyle('display','none');
                      rowS5ModWidth.setStyle('display','none');
                      rowS5StyleEffect.setStyle('display','none');
                      rowS5ImgWidth.setStyle('display','none');
                      rowS5ImgHeight.setStyle('display','none');
                      rowS5ReadMore.setStyle('display','none');   
                    break;
                    case "jv_slide3":
                      rowS1EventType.setStyle('display','none');
                      rowAuto.setStyle('display','none'); 
                      rowS2ModWidth.setStyle('display','none');
                      rowS2StyleEffect.setStyle('display','none');
                      rowS4NoItem.setStyle('display','none'); 
                      rowS4FrameWidth.setStyle('display','none');
                      rowS3SlideWidth.setStyle('display','');
                      rowS3SlideBarWidth.setStyle('display','');
                      rowS3ItemHeight.setStyle('display','');
                      rowS3ImgWidth.setStyle('display','');
                      rowS3ImgHeight.setStyle('display','');
                      rowS3StyleEffect.setStyle('display','');
                      rowS5ModWidth.setStyle('display','none');
                      rowS5StyleEffect.setStyle('display','none');
                      rowS5ImgWidth.setStyle('display','none');
                      rowS5ImgHeight.setStyle('display','none');
                      rowS5ReadMore.setStyle('display','none');  
                    break;
                    case "jv_slide4":
                     rowS1EventType.setStyle('display','none');
                      rowAuto.setStyle('display',''); 
                      rowS2ModWidth.setStyle('display','none');
                      rowS2StyleEffect.setStyle('display','none');
                      rowS4NoItem.setStyle('display',''); 
                      rowS4FrameWidth.setStyle('display','');
                      rowS3SlideWidth.setStyle('display','none');
                      rowS3SlideBarWidth.setStyle('display','none');
                      rowS3ItemHeight.setStyle('display','none');
                      rowS3ImgWidth.setStyle('display','none');
                      rowS3ImgHeight.setStyle('display','none');
                      rowS3StyleEffect.setStyle('display','none');
                      rowS5ModWidth.setStyle('display','none');
                      rowS5StyleEffect.setStyle('display','none');
                      rowS5ImgWidth.setStyle('display','none');
                      rowS5ImgHeight.setStyle('display','none');
                      rowS5ReadMore.setStyle('display','none');  
                    break;
                    case "jv_slide5":
                      rowS1EventType.setStyle('display','none');
                      rowAuto.setStyle('display','none'); 
                      rowS2ModWidth.setStyle('display','none');
                      rowS2StyleEffect.setStyle('display','none');
                      rowS4NoItem.setStyle('display','none'); 
                      rowS4FrameWidth.setStyle('display','none');
                      rowS3SlideWidth.setStyle('display','none');
                      rowS3SlideBarWidth.setStyle('display','none');
                      rowS3ItemHeight.setStyle('display','none');
                      rowS3ImgWidth.setStyle('display','none');
                      rowS3ImgHeight.setStyle('display','none');
                      rowS3StyleEffect.setStyle('display','none');
                      rowS5ModWidth.setStyle('display','');
                      rowS5StyleEffect.setStyle('display','');
                      rowS5ImgWidth.setStyle('display','');
                      rowS5ImgHeight.setStyle('display','');
                      rowS5ReadMore.setStyle('display','');    
                    break;
                }              
                     
              $('paramslayout_style').addEvent('change',function(){
                    selectStyle(this.value);                
              });
			 var selectStyle = function(style){
                 switch(style){
                    case "jv_slide1":
                      rowS1EventType.setStyle('display','');
                      rowAuto.setStyle('display',''); 
                      rowS2ModWidth.setStyle('display','none');
                      rowS2StyleEffect.setStyle('display','none');
                      rowS4NoItem.setStyle('display','none'); 
                      rowS4FrameWidth.setStyle('display','none');
                      rowS3SlideWidth.setStyle('display','none');
                      rowS3SlideBarWidth.setStyle('display','none');
                      rowS3ItemHeight.setStyle('display','none');
                      rowS3ImgWidth.setStyle('display','none');
                      rowS3ImgHeight.setStyle('display','none');
                      rowS3StyleEffect.setStyle('display','none');
                      rowS5ModWidth.setStyle('display','none');
                      rowS5StyleEffect.setStyle('display','none');
                      rowS5ImgWidth.setStyle('display','none');
                      rowS5ImgHeight.setStyle('display','none');
                      rowS5ReadMore.setStyle('display','none');                      
                    break;
                    case "jv_slide2":
                      rowS1EventType.setStyle('display','none');
                      rowAuto.setStyle('display',''); 
                      rowS2ModWidth.setStyle('display','');
                      rowS2StyleEffect.setStyle('display','');
                      rowS4NoItem.setStyle('display','none'); 
                      rowS4FrameWidth.setStyle('display','none');
                      rowS3SlideWidth.setStyle('display','none');
                      rowS3SlideBarWidth.setStyle('display','none');
                      rowS3ItemHeight.setStyle('display','none');
                      rowS3ImgWidth.setStyle('display','none');
                      rowS3ImgHeight.setStyle('display','none');
                      rowS3StyleEffect.setStyle('display','none');
                      rowS5ModWidth.setStyle('display','none');
                      rowS5StyleEffect.setStyle('display','none');
                      rowS5ImgWidth.setStyle('display','none');
                      rowS5ImgHeight.setStyle('display','none');
                      rowS5ReadMore.setStyle('display','none');   
                    break;
                    case "jv_slide3":
                      rowS1EventType.setStyle('display','none');
                      rowAuto.setStyle('display','none'); 
                      rowS2ModWidth.setStyle('display','none');
                      rowS2StyleEffect.setStyle('display','none');
                      rowS4NoItem.setStyle('display','none'); 
                      rowS4FrameWidth.setStyle('display','none');
                      rowS3SlideWidth.setStyle('display','');
                      rowS3SlideBarWidth.setStyle('display','');
                      rowS3ItemHeight.setStyle('display','');
                      rowS3ImgWidth.setStyle('display','');
                      rowS3ImgHeight.setStyle('display','');
                      rowS3StyleEffect.setStyle('display','');
                      rowS5ModWidth.setStyle('display','none');
                      rowS5StyleEffect.setStyle('display','none');
                      rowS5ImgWidth.setStyle('display','none');
                      rowS5ImgHeight.setStyle('display','none');
                      rowS5ReadMore.setStyle('display','none');  
                    break;
                    case "jv_slide4":
                     rowS1EventType.setStyle('display','none');
                      rowAuto.setStyle('display',''); 
                      rowS2ModWidth.setStyle('display','none');
                      rowS2StyleEffect.setStyle('display','none');
                      rowS4NoItem.setStyle('display',''); 
                      rowS4FrameWidth.setStyle('display','');
                      rowS3SlideWidth.setStyle('display','none');
                      rowS3SlideBarWidth.setStyle('display','none');
                      rowS3ItemHeight.setStyle('display','none');
                      rowS3ImgWidth.setStyle('display','none');
                      rowS3ImgHeight.setStyle('display','none');
                      rowS3StyleEffect.setStyle('display','none');
                      rowS5ModWidth.setStyle('display','none');
                      rowS5StyleEffect.setStyle('display','none');
                      rowS5ImgWidth.setStyle('display','none');
                      rowS5ImgHeight.setStyle('display','none');
                      rowS5ReadMore.setStyle('display','none');  
                    break;
                    case "jv_slide5":
                      rowS1EventType.setStyle('display','none');
                      rowAuto.setStyle('display','none'); 
                      rowS2ModWidth.setStyle('display','none');
                      rowS2StyleEffect.setStyle('display','none');
                      rowS4NoItem.setStyle('display','none'); 
                      rowS4FrameWidth.setStyle('display','none');
                      rowS3SlideWidth.setStyle('display','none');
                      rowS3SlideBarWidth.setStyle('display','none');
                      rowS3ItemHeight.setStyle('display','none');
                      rowS3ImgWidth.setStyle('display','none');
                      rowS3ImgHeight.setStyle('display','none');
                      rowS3StyleEffect.setStyle('display','none');
                      rowS5ModWidth.setStyle('display','');
                      rowS5StyleEffect.setStyle('display','');
                      rowS5ImgWidth.setStyle('display','');
                      rowS5ImgHeight.setStyle('display','');
                      rowS5ReadMore.setStyle('display','');    
                    break;
                }
              }              
		  });
		</script>
		<?php
		/*
		$js = "window.addEvent('domready',function(){
	           
	       });		
		";
		
		$doc = & JFactory::getDocument();
        $doc->addScriptDeclaration($js);   */  	
		return JHTML::_('select.genericlist',  $options, ''.$control_name.'['.$name.']', $class, 'value', 'text', $value, $control_name.$name);
	}
}
